﻿using System;
using System.Collections.Generic;
using System.Diagnostics;

using ReflectSoftware.Insight;

namespace Sample.DebugTrace
{
    class Program
    {
        static void TestTrace()
        {
            while (true)
            {
                Console.WriteLine("Press any key or 'q' to quit TestTrace()...");
                ConsoleKeyInfo k = Console.ReadKey();
                if (k.KeyChar == 'q')
                    break;

                Trace.Write("Hey1");
                Trace.Indent();
                Trace.Write("Hey2");
                Trace.Indent();
                Trace.TraceWarning("Warn");
                Trace.Fail("Failed");

                Trace.Indent();
                Trace.WriteLine("hello1");
                Trace.Indent();
                Trace.TraceInformation("Info");
                Trace.TraceInformation("Info");
                Trace.Indent();
                Trace.TraceWarning("Warn");
                Trace.Unindent();
                Trace.Unindent();
                Trace.TraceError("Error");
                Trace.Unindent();

                Trace.Unindent();
                Trace.Unindent();
                Trace.WriteLine("nextline");
            }
        }

        static void TestDebug()
        {
            while (true)
            {
                Console.WriteLine("Press any key or 'q' to quit TestDebug()...");
                ConsoleKeyInfo k = Console.ReadKey();
                if (k.KeyChar == 'q')
                    break;

                Debug.Write("Hey1");
                Debug.Indent();
                Debug.Write("Hey2");
                Debug.Indent();                
                Debug.Fail("Failed");

                Debug.Indent();
                Debug.WriteLine("hello1");
                Debug.Indent();
                Debug.Indent();                
                Debug.Unindent();
                Debug.Unindent();                
                Debug.Unindent();

                Debug.Unindent();
                Debug.Unindent();
                Debug.WriteLine("nextline");
            }
        }
        
        static void Main(string[] args)
        {
            // if you perfer to not use the config file settings then uncommen this line.
            //RITraceListener.Enabled = true;
            try
            {
                TestTrace();
                TestDebug();
            }
            finally
            {
                // if you perfer to not use the config file settings then uncommen this line.
                //RITraceListener.Enabled = false; // release any related resources
            }
        }
    }
}
